home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / sdf / cdf_cat.pro next >
Text File  |  1997-07-08  |  2KB  |  72 lines

  1. ;
  2. ;    Test program: CATalog of a CDF file
  3. ;
  4. ;
  5. pro cdf_cat,filename
  6.  
  7.     cdfid = cdf_open(filename)    ; Open a CDF file
  8.     glob = cdf_inquire( cdfid )    ; Find out general info
  9.  
  10.     ;    Tell user about each dimension
  11.  
  12.     print,'Dimensions', glob.ndims
  13.     for i=0,glob.ndims-1 do begin
  14.         print,FORMAT='("    Dim #", I0, ": ", I0)', i, glob.dim[i]
  15.     endfor
  16.  
  17.     ;    Get global attributes
  18.  
  19.     print_title = 1
  20.  
  21.     for attr_num = 0,glob.natts-1 do begin
  22.         cdf_attinq, cdfid, attr_num, attname, scope, maxentry
  23.         if scope eq "GLOBAL_SCOPE" then begin
  24.             ; assume there is only one entry and it
  25.             ; is at maxentry.
  26.             On_IoError, NoGlobAttr
  27.             cdf_attget, cdfid, attr_num, maxentry, attvalue
  28.             if print_title then begin
  29.                 print
  30.                 print, 'Global Attributes'
  31.                 print
  32.                 print_title = 0
  33.             endif
  34.             Print, "Attribute: '", attname, "' = ", attvalue
  35.         NoGlobAttr:
  36.         endif
  37.     endfor
  38.     ;    Now tell user about the variables
  39.  
  40.     print
  41.     print, 'Variables'
  42.     print
  43.     for var_num=0,glob.nvars-1 do begin
  44.  
  45.         ;    Get information about the variable
  46.  
  47.         info = cdf_varinq(cdfid, var_num)
  48.  
  49.         ; Print the name, type and per record variance of the
  50.         ; variable
  51.         print, FORMAT='(A," (",A," ) Record Variance:", A)', $
  52.             info.name, info.datatype, info.recvar
  53.  
  54.         ; print any attributes associated with the variable
  55.  
  56.         ;    The attribute may not have a value
  57.         ;    associate the given variable.
  58.         On_IoError, NoAttr
  59.  
  60.         ;    Loop through all the attributes and see if
  61.         ;    there is an entry for the given variable
  62.  
  63.         for attr_num=0,glob.natts-1 do begin
  64.             cdf_attinq, cdfid, attr_num, attname, scope, maxentry
  65.             cdf_attget, cdfid, attr_num, var_num, attvalue
  66.             print,"    Attribute: '", attname, "' = ", attvalue
  67.         NoAttr:
  68.         endfor
  69.     endfor
  70.     cdf_close,cdfid
  71. end
  72.